package org.tigris.mappedlexer.validator.implementation;

import org.tigris.mappedlexer.validator.VerifyHub;

/**
 * Verify input if they are indentifiers.
 * 
 * @author zhisen.huang
 */
public class IdentifierValidator extends AbstractValidator {

	/**
	 * Get the next token with the constraints.
	 * 
	 * @param validators the constraints
	 */
	@Override
	public boolean validate(String str) throws UnsupportedOperationException {
		if (VerifyHub.ALPHA.validate(str.charAt(0))) {
			for (int i = 1; i < str.length(); i++) {
				if (!VerifyHub.ALPHANUMERIC.validate(str.charAt(i))) {
					return false;
				}
			}
			return true;
		}
		return false;
	}

}
